package com.kuqi.crs.workbench.service.Impl;

import com.kuqi.crs.util.SqlSessionUtil;
import com.kuqi.crs.vo.PaginationVO;
import com.kuqi.crs.workbench.dao.ClueDao;
import com.kuqi.crs.workbench.domain.Clue;
import com.kuqi.crs.workbench.service.ClueService;

import java.util.List;
import java.util.Map;

/**
 * @author:kuqi
 * @createTime:2021/10/6 15:47
 * @description:
 */
public class ClueServiceImpl implements ClueService {
    private ClueDao clueDao = SqlSessionUtil.getSqlSession().getMapper(ClueDao.class);

    public boolean save(Clue c) {
        boolean flag = true;
        int count = clueDao.save(c);
        if (count != 1){
            flag = false;
        }
        return flag;
    }

    public PaginationVO getClueList(Map<String, Object> map) {
        PaginationVO<Clue> vo = new PaginationVO<Clue>();
        int total = clueDao.getTotal();//获取所有的线索条数，前端用于分页查询
        List<Clue> clueList = clueDao.getClueListByCondition(map);//后台分页查询数据库列表

        vo.setTotal(total);
        vo.setDataList(clueList);

        return vo;
    }
}
